<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <!--IE Compatibility modes-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--Mobile first-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>403</title>

    <meta name="description" content="Free Admin Template Based On Twitter Bootstrap 3.x">
    <meta name="author" content="">

    <meta name="msapplication-TileColor" content="#5bc0de"/>
    <meta name="msapplication-TileImage" content="assets/img/metis-tile.png"/>

    <!-- Bootstrap -->
    <link href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- Font Awesome -->
    <!--<link rel="stylesheet" href="assets/lib/font-awesome/css/font-awesome.min.css">-->
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="/assets/lib/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet" href="/assets/lib/bootstrap-switch/css/bootstrap3/bootstrap-switch.min.css">
    <!-- Metis core stylesheet -->
    <link rel="stylesheet" href="/assets/css/main.css">
    <!-- animate.css stylesheet -->
    <link rel="stylesheet" href="/assets/lib/animate.css/animate.css"/>
    <link rel="stylesheet" href="/assets/lib/select2/css/select2.min.css"/>
    <link rel="stylesheet" href="/assets/lib/bootstrap-validator/css/bootstrapValidator.min.css"/>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="//oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <style>
        .text_info {
            border: 0px;
        }
    </style>


    <![endif]-->
</head>

<body>
<div class="bg-dark dk" id="wrap" style="height:50px;">
    <header class="head">
        <div class="">
            <ol class="breadcrumb" style="background-color: #3a3a3a">
                <li><a href="#"> <i class="fa fa-home"> 店铺管理</i></a></li>
                <li class="active">店铺申请</li>
            </ol>
        </div>
        <!-- /.main-bar -->
    </header>
</div>
<div class="container" style="width:100%;">
    <div class="row">
        <div class="col-lg-12">
            <div class="box dark">
                <header>
                    <div class="icons"><i class="fa fa-th-large"></i></div>
                    <h5>查询</h5>
                    <!-- .toolbar -->
                    <div class="toolbar">
                        <nav style="padding: 8px;">
                        </nav>
                    </div>            <!-- /.toolbar -->
                </header>
                <div id="div-1" class="body">
                    <form id="validVal" class="form-inline">
                        <div class="form-group">
                            <label for="contactor">联系人&nbsp;</label>
                            <input type="text" name="contactor" class="form-control" id="contactor"
                                   placeholder="请输入联系人">
                        </div>
                        <div class="form-group">
                            <label for="contactPhone">联系手机&nbsp;</label>
                            <input type="text" name="contactPhone" class="form-control" id="contactPhone"
                                   placeholder="请输入联系手机">
                        </div>
                        <div class="form-group">
                            <label for="contactTel">联系电话&nbsp;</label>
                            <input type="text" name="contactTel" class="form-control" id="contactTel"
                                   placeholder="请输入联系电话">
                        </div>
                        <div class="form-group">
                            <label for="merchantName">店铺名&nbsp;</label>
                            <input type="text" name="merchantName" class="form-control" id="merchantName"
                                   placeholder="请输入店铺名">
                        </div>
                        <div class="form-group">
                            <label for="type" class=" control-label">类型&nbsp;</label>
                            <select name="type" id="type" class="form-control">
                                <option>请选择</option>
                                <option value="餐饮">餐饮</option>
                                <option value="娱乐">娱乐</option>
                                <option value="住宿">住宿</option>
                                <option value="生活">生活</option>
                                <option value="艺术">艺术</option>
                                <option value="教育">教育</option>
                                <option value="企业">企业</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label for="status">审核状态&nbsp;</label>
                            <select name="status" id="status" class="form-control">
                                <option>请选择</option>
                                <option value="0">待审核</option>
                                <option value="1">审核通过</option>
                                <option value="2">审核拒绝</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="licenceNo">营业执照编号&nbsp;</label>
                            <input type="text" name="licenceNo" class="form-control" id="licenceNo"
                                   placeholder="请输入营业执照编号">
                        </div>
                        <div class="form-group">
                            <div id="distpicker2">
                                <select name="province" id="province" class="form-control"></select>
                                <select name="city" id="city" class="form-control"></select>
                                <select name="region" id="region" class="form-control"></select>
                            </div>
                        </div>

                        <button type="button" class="btn btn-success search_button">提交</button>

                    </form>
                </div>
            </div>
        </div>

        <!--END TEXT INPUT FIELD-->
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="box">
                <div id="collapse4" class="body">
                    <!-- <div id="toolbar" style="margin-bottom: 5px;">
                         <div id="toolbar" style="margin-bottom: 5px;">
                             <div class="btn-group">
                                 <button type="button"data-toggle="modal"   data-target="#add_modal" class="btn btn-default"><i class="fa fa-plus"></i>&nbsp;新增 </button>
                             </div>
                         </div>
                     </div>-->
                    <table id="dataTable" class="table table-bordered table-condensed table-hover table-striped">
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!-- /.col-lg-8 col-offset-2 -->
    <!--------------------------添加用户的弹出层---------------------------->
    <div id="add_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         data-backdrop="static"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header bg-primary">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>


                    <h5 class="modal-title">
                        <i class="icon-pencil"></i>
                        <span data-type="add" style="font-weight:bold">添加用户</span>
                    </h5>
                </div>
                <form class="form-horizontal form-bordered form-row-strippe" id="add_form" action=""
                      data-toggle="validator" enctype="multipart/form-data">
                    <div class="modal-body">
                        <input name="id" type="hidden" value=""/>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">用户名称</label>
                                    <div class="col-md-10">
                                        <input name="username" type="text" class="form-control"
                                               placeholder="用户名称..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">密码</label>
                                    <div class="col-md-10">
                                        <input name="password" type="text" class="form-control"
                                               placeholder="密码..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">手机号</label>
                                    <div class="col-md-10">
                                        <input name="phone" type="text" class="form-control"
                                               placeholder="手机号..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">邮箱</label>
                                    <div class="col-md-10">
                                        <input name="email" type="text" class="form-control"
                                               placeholder="邮箱..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">角色</label>
                                    <div class="col-md-10">
                                        <select class="js-example-basic-single role_select" multiple="multiple"
                                                name="roleIds">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">状态</label>
                                    <div class="col-md-10">
                                        <select class="form-control" name="enabled">
                                            <option value="1">正常</option>
                                            <option value="0">冻结</option>
                                        </select>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="modal-footer bg-info">
                        <input type="hidden" id="ID" name="ID"/>
                        <button type="submit" id="add_button" class="btn blue">确定</button>
                        <button type="button" class="btn green" data-dismiss="modal">取消</button>
                    </div>
                    <div class="alert alert-danger error_div" style="text-align: center;display: none;">
                        <strong>错误!</strong><span></span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /modal -->

    <!--------------------------添加用户的弹出层---------------------------->
    <div id="update_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         data-backdrop="static"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header bg-primary">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>


                    <h5 class="modal-title">
                        <i class="icon-pencil"></i>
                        <span id="lblAddTitle" data-type="add" style="font-weight:bold">修改用户</span>
                    </h5>
                </div>
                <form class="form-horizontal form-bordered form-row-strippe" id="update_form" action=""
                      data-toggle="validator" enctype="multipart/form-data">
                    <input name="id" type="hidden" value=""/>
                    <div class="modal-body">
                        <input name="id" type="hidden" value=""/>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">用户名称</label>
                                    <div class="col-md-10">
                                        <input name="username" type="text" class="form-control"
                                               placeholder="用户名称..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">手机号</label>
                                    <div class="col-md-10">
                                        <input name="phone" type="text" class="form-control"
                                               placeholder="手机号..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">邮箱</label>
                                    <div class="col-md-10">
                                        <input name="email" type="text" class="form-control"
                                               placeholder="邮箱..."/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">角色</label>
                                    <div class="col-md-10">
                                        <select class="js-example-basic-single role_select" multiple="multiple"
                                                name="roleIds">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="control-label col-md-2">状态</label>
                                    <div class="col-md-10">
                                        <label name="enabled" type="text" class="form-control text_info"></label>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="modal-footer bg-info">
                        <input type="hidden" id="ID" name="ID"/>
                        <button type="submit" id="update_button" class="btn blue">确定</button>
                        <button type="button" class="btn green" data-dismiss="modal">取消</button>
                    </div>
                    <div class="alert alert-danger error_div" style="text-align: center;display: none;">
                        <strong>错误!</strong><span></span>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /modal -->


    <!-- 模态框（Modal） -->

    <div class="modal fade" id="ShowImage_Form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog" id="modal111" style="width: 500px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                </div>
                <div class="modal-body">
                    <div id="img_show">
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

</div>
<!--jQuery -->
<script src="/assets/lib/jquery/jquery.min.js"></script>
<!--Bootstrap -->
<script src="/assets/lib/bootstrap/js/bootstrap.min.js"></script>
<script src="/assets/lib/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/assets/lib/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/assets/lib/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<script src="/assets/lib/select2/js/select2.min.js"></script>
<script src="/assets/lib/bootstrap-validator/js/bootstrapValidator.min.js"></script>
<!-- MetisMenu -->
<script src="/assets/lib/metismenu/metisMenu.js"></script>
<!-- Metis core scripts -->
<script src="/assets/js/core.js"></script>
<script src="/assets/js/distpicker.data.js"></script>
<script src="/assets/js/distpicker.js"></script>


<!-- Metis demo scripts -->
<script src="/assets/js/app.js"></script>
<script src="/assets/lib/layer/layer.js"></script>
<script>
    var csrf_token = "${_csrf.token}";
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': csrf_token
        }
    });
    layer.config({
        extend: 'extend/layer.ext.js'
    });

  	//每隔10分钟刷新
	setInterval(function(){
		$('table').bootstrapTable('refresh');
	}, 600000);

    $(document).ready(function () {


        $("#distpicker2").distpicker({
            province: "---- 所在省 ----",
            city: "---- 所在市 ----",
            district: "---- 所在区 ----"
        });
        $("#distpicker2").distpicker('reset', true);

        $('#add_modal,#update_modal').on('hide.bs.modal', function () {
            $(this).find(".error_div").hide();
        });
        $('#add_modal').on('show.bs.modal', function (e) {
            $.ajax({
                type: "GET",
                dataType: "json",
                url: "/sys/get/roles",
                beforeSend: function () {
                },
                success: function (res) {
                    if (res.status) {
                        layer.msg("获取角色失败", {icon: 7});
                    } else {
                        $(e.target).find(".role_select").select2({
                            width: "100%",
                            tags: true,
                            maximumSelectionLength: 3,
                            data: res,
                            placeholder: "请选择角色"
                        });

                    }
                },
                error: function (xhr, errorType, error) {
                    layer.msg("获取角色失败", {icon: 7});
                },
                complete: function () {
                }
            });
        });
        initTable();

        $(document).on("click", ".search_button", function () {
            $('table').bootstrapTable('refresh');
        });

        $("#add_form").bootstrapValidator(
            {
                message: 'This value is not valid',
                submitButtons: 'button[type="submit"]',
                live: 'enabled',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    username: {
                        validators: {
                            notEmpty: {
                                message: "用户名不为空"
                            },
                            stringLength: {
                                max: 30,
                                message: "用户名不大于30字符"
                            },
                            remote: {
                                message: "用户已存在",
                                url: "/sys/check/user/username",
                                delay: 2000
                            }
                        }
                    },
                    password: {
                        validators: {
                            notEmpty: {
                                message: "密码不为空"
                            }
                        }
                    },
                    phone: {
                        validators: {
                            notEmpty: {
                                message: "手机号不为空"
                            },
                            phone: {
                                country: 'CN',
                                message: "手机号不正确"
                            },
                            remote: {
                                message: "手机号已存在",
                                url: "/sys/check/user/phone",
                                delay: 2000
                            }
                        }
                    },
                    email: {
                        validators: {
                            emailAddress: {
                                message: '邮箱地址格式有误'
                            }
                        }
                    },
                    role: {
                        validators: {
                            notEmpty: {
                                message: "角色不为空"
                            }
                        }
                    }
                }
            }
        ).on('success.form.bv', function (e) {
            // Prevent form submission
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target);
            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            // Use Ajax to submit form data 提交至form标签中的action，result自定义
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/sys/add/user",
                data: $form.serialize(),
                beforeSend: function () {
                },
                success: function (res) {
                    if (res.status == "y") {
                        $("#add_modal").modal("hide");
                        $("table").bootstrapTable('refresh');
                        layer.msg("添加成功!", {icon: 6});
                    } else {
                        showError($form, res.info);
                    }
                },
                error: function (xhr, errorType, error) {
                    showError($form, error);
                },
                complete: function () {
                }
            });
        });
    });

    $("#update_form").bootstrapValidator(
        {
            message: 'This value is not valid',
            submitButtons: 'button[type="submit"]',
            live: 'enabled',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                username: {
                    validators: {
                        notEmpty: {
                            message: "用户名不为空"
                        },
                        stringLength: {
                            max: 30,
                            message: "用户名不大于30字符"
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {
                            message: "密码不为空"
                        }
                    }
                },
                phone: {
                    validators: {
                        notEmpty: {
                            message: "手机号不为空"
                        },
                        phone: {
                            country: 'CN',
                            message: "手机号不正确"
                        }

                    }
                },
                email: {
                    validators: {
                        emailAddress: {
                            message: '邮箱地址格式有误'
                        }
                    }
                },
                role: {
                    validators: {
                        notEmpty: {
                            message: "角色不为空"
                        }
                    }
                }
            }
        }
    ).on('success.form.bv', function (e) {
        // Prevent form submission
        e.preventDefault();
        // Get the form instance
        var $form = $(e.target);
        // Get the BootstrapValidator instance
        var bv = $form.data('bootstrapValidator');
        // Use Ajax to submit form data 提交至form标签中的action，result自定义
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "/sys/update/user",
            data: $form.serialize(),
            beforeSend: function () {
            },
            success: function (res) {
                if (res.status == "y") {
                    $("#update_modal").modal("hide");
                    $("table").bootstrapTable('refresh');
                    layer.msg("修改成功!", {icon: 6});
                } else {
                    showError($form, res.info);
                }
            },
            error: function (xhr, errorType, error) {
                showError($form, error);
            },
            complete: function () {
            }
        });
    });
    function showError(obj, error) {
        obj.find(".error_div").find("span").text(error);
        obj.find(".error_div").show();
    }
    function initTable() {
        var url = "/sysu/getStoreApply";
        $('table').bootstrapTable({
            method: 'GET',
            dataType: 'json',
            contentType: "application/x-www-form-urlencoded",
            cache: false,
            striped: true,                              //是否显示行间隔色
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            url: url,
            sortable: true,
            sortName: "createTime",
            sortOrder: 'desc',
            showColumns: false,
            pagination: true,
            queryParams: queryParams,
            minimumCountColumns: 2,
            pageNumber: 1,                       //初始化加载第一页，默认第一页
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
            uniqueId: "id",                     //每一行的唯一标识，一般为主键列
            showExport: true,
            exportDataType: 'all',
            responseHandler: responseHandler,
            columns: [
                {
                    field: 'id',
                    title: '序列号',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        var pageSize = $('table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
//                        return pageSize * (pageNumber - 1) + index + 1;    //返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                        return "<span data-id='" + value + "'>" + (pageSize * (pageNumber - 1) + index + 1) + "</span>";
                    }
                },
                {
                    field: 'type',
                    title: '类型',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'merchantName',
                    title: '店铺名',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'status',
                    title: '审核状态',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "<span style='color: blue'>待审核</span>";
                        } else if (value == 1) {
                            return "<span style='color: green'>审核通过</span>";
                        } else if (value == 2) {
                            return "<span style='color: red'>审核拒绝</span>";
                        } else {
                            return "<span style='color: blue'>未知状态</span>";
                        }
                    }
                },
                {
                    field: 'invited',
                    title: '邀请人',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'register',
                    title: '注册人',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'contactor',
                    title: '联系人',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'contactPhone',
                    title: '联系手机',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'contactTel',
                    title: '联系电话',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    field: 'province',
                    title: '省',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'city',
                    title: '市',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'region',
                    title: '区',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'address',
                    title: '详细地址',
                    align: 'center',
                    valign: 'middle'
                }, {
                    field: 'licenceImg',
                    title: '营业执照照片',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return "<img  src=" + value + " width='72' height='72' alt='' class='img-rounded' onclick='showimage(\"" + value + "\");'/>";
                    }
                }, {
                    field: 'identityAImg',
                    title: '身份证正面照',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return "<img  src=" + value + " width='72' height='72' alt='' class='img-rounded' onclick='showimage(\"" + value + "\");'/>";
                    }
                }, {
                    field: 'identityBImg',
                    title: '身份证背面照',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return "<img  src=" + value + " width='72' height='72' alt='' class='img-rounded' onclick='showimage(\"" + value + "\");'/>";
                    }
                }, {
                    field: 'storeImg',
                    title: '店铺/企业照',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return "<img  src=" + value + " width='72' height='72' alt='' class='img-rounded' onclick='showimage(\"" + value + "\");'/>";
                    }
                }, {
                    field: 'licenceNo',
                    title: '营业执照编号',
                    align: 'center',
                    valign: 'middle',
                }, {
                    field: 'createTime',
                    title: '创建时间',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        return new Date(value).format('yyyy-MM-dd hh:mm:ss');
                    }
                }, {
                    field: '',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: function (value, row, index) {
                        var strHtml="";
                        if(row.status==0){
                            strHtml = '<a title="审核通过"  href="javascript:void(0);"  class="btn btn-xs btn-success apply-pass" ><i class="fa fa-check bigger-120"></i></a>' +
                                '&nbsp;<a  href="javascript:;" title="审核拒绝" class="btn btn-xs btn-danger apply-refuse"><i class="fa fa-close  bigger-120"></i></a>';

                        }else {
                            strHtml='无操作选项';
                        }
                        return strHtml;
                    }
                }],
            onPostBody: function () {
                $(".make-switch").bootstrapSwitch({
                    onSwitchChange: function (event, state) {
                        var userId = $(event.target).closest("tr").find("td:first").find("span").attr("data-id");
                        $.ajax({
                            type: "POST",
                            dataType: "json",
                            url: "/sys/enable/user",
                            data: {
                                userId: userId,
                                enabled: state
                            },
                            beforeSend: function () {
                            },
                            success: function (res) {
                                if (res.status != "y") {
                                    layer.msg("操作失败", {icon: 7});
                                    $("table").bootstrapSwitch('state', !state, true);
                                }
                            },
                            error: function (xhr, errorType, error) {
                                layer.msg("操作失败", {icon: 7});
                                $(event.target).bootstrapSwitch('state', !state, true);
                            },
                            complete: function () {
                            }
                        });
                    }
                });
            }
        });

        $(document).on("click", ".apply-refuse", function (event) {
            var id = $(event.target).closest("tr").find("td:first").find("span").attr("data-id");
            layer.prompt({title: '是否拒绝该条申请？请输入拒绝原因', formType: 2}, function(pass, index){
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "/sysu/storeApply/refuse",
                    async:false,
                    data: {
                        id: id,
                        reason:pass
                    },
                    success: function (res) {
                        if (res.status != "y") {
                            layer.msg("操作失败", {icon: 7});

                        } else {
                            $("table").bootstrapTable('refresh');
                            layer.msg("审核拒绝成功", {icon: 6});
                        }
                    },
                    error: function (xhr, errorType, error) {
                        layer.msg("操作失败", {icon: 7});
                    }
                });
            });

        });


        $(document).on("click", ".apply-pass", function (e) {
            var id = $(e.target).closest("tr").find("td:first").find("span").attr("data-id");

            layer.confirm('确定通过该条申请吗?', {icon: 3, title:'提示'}, function(index){
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "/sysu/storeApply/pass",
                    async:false,
                    data: {
                        id: id
                    },
                    success: function (res) {
                        if (res.status != "y") {
                            layer.msg("操作失败", {icon: 7});

                        } else {
                            $("table").bootstrapTable('refresh');
                            layer.msg("审核通过成功", {icon: 6});
                        }
                    },
                    error: function (xhr, errorType, error) {
                        layer.msg("操作失败", {icon: 7});
                    }
                });
            });
        });
    }

    function showimage(source) {
        $("#ShowImage_Form").find("#img_show").html("<image id='myimage' src=" + source + " class='carousel-inner img-responsive img-rounded' />");


        //添加鼠标滚轮事件处理代码
        var myimage = document.getElementById("modal111");

        if (myimage.addEventListener) {
            // IE9, Chrome, Safari, Opera
            myimage.addEventListener("mousewheel", MouseWheelHandler, false);
            // Firefox
            myimage.addEventListener("DOMMouseScroll", MouseWheelHandler, false);
        }
        // IE 6/7/8
        else myimage.attachEvent("onmousewheel", MouseWheelHandler);
        //为了让不同浏览器都能支持的处理做法,我们将对Firefox的detail值取反然后返回1或者-1的其中一个
        function MouseWheelHandler(e) {
            // cross-browser wheel delta
            var e = window.event || e; // old IE support
            var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
            //现在我们直接决定图片的大小范围。以下代码将图片的宽度范围设置在50-800个像素之间
            myimage.style.width = Math.max(50, Math.min(800, parseInt(myimage.style.width.replace("px","")) + (30 * delta))) + "px";
            // 最后一点，我们在方法中返回false是为了终止标准的鼠标滚轮事件处理，以防它上下滑动网页
            return false;
        }

        $("#ShowImage_Form").modal();
    }


    function queryParams(params) {
        var param = {
            pageNumber: this.pageNumber,
            pageSize: this.pageSize,
            contactor: $("form").find("[name='contactor']").val(),
            contactPhone: $("form").find("[name='contactPhone']").val(),
            contactTel: $("form").find("[name='contactTel']").val(),
            merchantName: $("form").find("[name='merchantName']").val(),
            licenceNo: $("form").find("[name='licenceNo']").val(),
        };

        if ($('#type option:selected').text().indexOf("请选择") == -1) {
            param.type = $('#type option:selected').text();
        }

        if ($('#status option:selected').text().indexOf("请选择") == -1) {
            param.status = $('#status option:selected').val();
        }

        if ($('#province option:selected').text().indexOf("所在省") == -1) {
            param.province = $('#province option:selected').text();
        }

        if ($('#city option:selected').text().indexOf("所在市") == -1) {
            param.city = $('#city option:selected').text();
        }

        if ($('#region option:selected').text().indexOf("所在区") == -1) {
            param.region = $('#region option:selected').text();
        }


        return param;
    }

    // 用于server 分页，表格数据量太大的话 不想一次查询所有数据，可以使用server分页查询，数据量小的话可以直接把sidePagination: "server"  改为 sidePagination: "client" ，同时去掉responseHandler: responseHandler就可以了，
    function responseHandler(res) {

        if (res) {
            return {
                "rows": res.result,
                "total": res.totalCount
            };
        } else {
            return {
                "rows": [],
                "total": 0
            };
        }
    }
    $.fn.modal.Constructor.prototype.enforceFocus = function () {
    };
    Date.prototype.format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
</script>
</body>

</html>
